 <table width="100%">
    <tr>
    <td height="5"></td>
  </tr>
   <tr><td><h1>Add User</h1></td>
  </tr>
  <tr>
    <td height="5"></td>
  </tr>
  <tr>
    <td><form id="form1" name="form1" method="post" action="/user/index/save-profile/" onsubmit="return validateRegistration();"><input type="hidden" name="uniqEmail" id="uniqEmail" value="0" /><input type="hidden" name="userId" id="userId" value="<?php echo $ctx->id;?>" /><input type="hidden" name="creby" id="creby" value="<?=SD_USER_ID?>" />
      <table width="98%" border="0" align="center" cellpadding="5" cellspacing="0" class="form_box">
	  <tr>
          <td align="left">&nbsp;</td>
          <td align="left">&nbsp;</td>
        </tr>
        <tr>
          <td width="44%" align="right"><span class="red_txt">*</span>First Name </td>
          <td width="56%" align="left"><input name="firstName" type="text" class="textfield" id="firstName" value="<?php echo $ctx->first_name;?>" title="Please Enter First Name" /><div  style="float:right; padding-right:130px; padding-top:8px;" id="divfirstName" class="validationError"></div></td>
        </tr>
          <tr>
          <td align="right"><span class="red_txt">*</span>Last Name</td>
          <td align="left"><input name="lastName" type="text" class="textfield" id="lastName" value="<?php echo $ctx->last_name;?>" title="Please Enter Last Name" />
          <div  style="float:right; padding-right:130px; padding-top:8px;" id="divLastName" class="validationError"></div></td>
        </tr>
        <tr>
          <td align="right"><span class="red_txt">*</span>Email Address </td>
          <td align="left"><input name="emailAddress" type="text" class="textfield" id="emailAddress" value="<?php echo $ctx->email_address;?>" title="Please Enter Email Address" onblur="checkUniqueEmail(this.value)" readonly="readonly" /><div  style="float:right; padding-right:130px; padding-top:8px;" id="divEmailAddress" class="validationError"></div></td>
        </tr>
       <!--<tr>
          <td align="right"><span class="red_txt">*</span>Password</td>
          <td align="left"><input type="password" name="password1" class="textfield" id="password1" title="Please Enter a Password." /><div  style="float:right; padding-right:130px; padding-top:8px;" id="divPassword1" class="validationError"></div></td>
        </tr>
       <tr>
          <td align="right"><span class="red_txt">*</span>Verify Password</td>
          <td align="left"><input type="text" name="password2" class="textfield" id="password2" title="Please Enter Verify Password" /><div  style="float:right; padding-right:130px; padding-top:8px;" id="divPassword2" class="validationError"></div></td>
        </tr> -->       
        <tr>
          <td align="right"><span class="red_txt">*</span>Role</td>
          <td align="left"><select name="role" id="role" title="Please Choose User Role" class="required" tal:define="utype userTypes | string:us | uty uty"><option value="">--Choose A Role--</option> <option value="" tal:repeat="opt utype" tal:attributes="value repeat/opt/key;selected php:repeat.opt.key == uty" tal:content="opt"></option>
</select><div  style="float:right; padding-right:130px; padding-top:8px;" id="divRole" class="validationError"></div>          </td>
        </tr>
        <tr>
          <td align="right"><span class="red_txt">*</span>Company Name</td>
          <td align="left"><input type="text" name="company" class="textfield" id="company" value="<?php echo $ctx->company_name;?>" title="Please Enter Company Name" /><div  style="float:right; padding-right:130px; padding-top:8px;" id="divCompany" class="validationError"></div></td>
        </tr>
        <tr>
          <td align="left">&nbsp;</td>
          <td align="left"><input type="submit" name="add" id="add" value="Update"  class="input_bt" />&nbsp;
            <input name="Input" type="button" value="Cancel" class="input_bt" onclick="location.href='/user/'"/>            </td>
        </tr>
        <tr>
          <td align="left">&nbsp;</td>
          <td align="left">&nbsp;</td>
        </tr>
      </table>     
        </form>
    </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr></table>
<script type="text/javascript">
//<![CDATA[
function checkUniqueEmail(email)
{
	if(email!='' && isValidEmailAddress(email)){
		$.ajax({
		type: "POST",
		url: "/register/index/uniqemail/",
		data: "email="+email,
		success: function(msg){
			if(msg!=''){
				$('#divEmailAddress').html(msg);
				document.getElementById('uniqEmail').value = 1; 
			} else {
				$('#divEmailAddress').html(msg);
				document.getElementById('uniqEmail').value = 0; 
			}
		}
		});
	} else {
		$('#divEmailAddress').html('Please Enter Valid Email Address');
	}	

}
function checkUniqueUserName(uname)
{
	if(uname!=''){
		$.ajax({
		type: "POST",
		url: "/register/index/uniqusername/",
		data: "userName="+uname,
		success: function(msg){
			if(msg!=''){
				$('#divUserName').html(msg);
				document.getElementById('uniqUser').value = 1; 
			} else {
				$('#divUserName').html(msg);
				document.getElementById('uniqUser').value = 0; 	
			}
		}
		});
	}	
}
function checkCaptcha(captValue)
{
	if(captValue!=''){
		$.ajax({
		type: "POST",
		url: "/register/index/chkcaptcha/",
		data: "captcha="+captValue,
		success: function(msg){
			$('#divcaptcha').html(msg);
			if(msg==''){
				document.getElementById('capField').value=1;
			}
		}
		});	
	}
}
function validate(element)
{		
		if($("#"+element).val()==''){
			
			var x= "div"+element;
		$("#div"+element).html($("#"+element).attr("title"));
		$("#div"+element).show('slow');
		$("#"+element).focus();
		return false;
	} else {
		$("#"+element).html('');
	}
}
function validateRegistration()
{
	if($('#firstName').val()==''){
		$('#divfirstName').html($('#firstName').attr("title"));
		$('#divfirstName').show('slow');
		$('#firstName').focus();
		return false;
	} else {
		$('#divfirstName').html('');
	}
		
	if($('#lastName').val()==''){
		$('#divLastName').html($('#lastName').attr("title"));
		$('#divLastName').show('slow');
		$('#lastName').focus();
		return false;
	} else {
		$('#divLastName').html('');
	}
	if($('#emailAddress').val()==''){
		$('#divEmailAddress').html($('#emailAddress').attr("title"));
		$('#divEmailAddress').show('slow');
		$('#emailAddress').focus();
		return false;
	} else {
		if(isValidEmailAddress($('#emailAddress').val()))
		{
			$('#divEmailAddress').html('');
		} else {
			$('#divEmailAddress').html('Please Enter Valid Email Address');
			return false;
		}
		
	}
	if($('#role').val()==''){
	$('#divRole').html($('#role').attr("title"));
		$('#divRole').show('slow');
		$('#role').focus();
		return false;
	} else {
		$('#divRole').html('');
	}
	if($('#company').val()==''){
	$('#divCompany').html($('#company').attr("title"));
		$('#divCompany').show('slow');
		$('#company').focus();
		return false;
	} else {
		$('#divCompany').html('');
	}
}
function isValidEmailAddress(emailAddress)
{

var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}
//]]>
</script>
